package com.lingxu.module.zx.util;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.Collection;

/**
 * 简单的判断参数是否为空的方法
 * wt
 */
public class CheckVariable {

    /**
     * 判断string是否为"" 或者为null
     *
     * @param str
     * @return 满足 true  不满足 false
     */
    public static boolean isEmpty(String str) {
        if (str == null || "".equals(str)) {
            return true;
        }
        return false;
    }

    public static boolean isEmpty(Long l) {
        if (l == null) {
            return true;
        }
        return false;
    }


    public static boolean isEmpty(Integer integer) {
        if (integer == null) {
            return true;
        }
        return false;
    }

    public static boolean isEmpty(Object[] obj) {
        if (obj == null || obj.length <= 0) {
            return true;
        }
        return false;
    }

    public static boolean isEmpty(MultipartFile multipartFile) {
        if (multipartFile == null || multipartFile.isEmpty() || multipartFile.getSize() <= 0) {
            return true;
        }
        return false;
    }

    public static boolean isEmpty(Collection list) {
        if (list == null || list.size() <= 0) {
            return true;
        }
        return false;
    }
    public static boolean isEmpty(File file) {
        if (file==null || !file.exists()) {
            return true;
        }
        return false;
    }

    public static boolean isEmpty(Object obj) {
        if (obj == null || "".equals(obj)) {
            return true;
        }
        return false;
    }


}
